class Solution {
public:
    vector<vector<int>> modifiedMatrix(vector<vector<int>>& matrix) {
        for (int i = 0; i < matrix[0].size(); i++)
        {
            int maxnum = -1;
            for (int j = 0; j < matrix.size(); j++)
                maxnum = max(maxnum, matrix[j][i]);
            for (int j = 0; j < matrix.size(); j++)
                matrix[j][i] = matrix[j][i] == -1 ? maxnum : matrix[j][i];
        }
        return matrix;
    }
};